//
//  TodayDetailCalendarCell.swift
//  MoyoungHome
//
//  Created by 易先生 on 2022/9/21.
//

import UIKit
import MYModule

class CalendarTableCell: CollectionViewCell {
    

	override func makeUI() {
		super.makeUI()

		contentView.addSubview(circleView)
		contentView.addSubview(dayLabel)

		circleView.snp.makeConstraints { make in
			make.edges.equalToSuperview()
            make.size.equalTo(48.0)
		}

		dayLabel.snp.makeConstraints { make in
			make.center.equalToSuperview()
		}
	}

	public func bind(to cellModel: CalendarModel) {
        
        
        dayLabel.isHidden = false
        circleView.isHidden = false
        
        switch cellModel.type {
            
        case .past:
            
            circleView.lineWidth = 1.0
            circleView.shapeLayer.fillColor = UIColor.clear.cgColor
            dayLabel.isHidden = true
            circleView.isHidden = true
            
            break
            
        case .empty:
            
            circleView.lineWidth = 1.0
            circleView.shapeLayer.fillColor = UIColor.clear.cgColor
            dayLabel.textColor = UIColor.assist_222222
            break
            
        case .real:
            
            circleView.lineWidth = 1.0
            var fillColor = cellModel.fillColor
            if cellModel.isSelected == false {
                fillColor = fillColor?.withAlphaComponent(0.8)
            }
            
            circleView.shapeLayer.fillColor = fillColor?.cgColor
            dayLabel.textColor = UIColor.assist_FFFFFF
            
        case .future:
            
            circleView.lineWidth = 1.0
            circleView.shapeLayer.fillColor = UIColor.clear.cgColor
            dayLabel.textColor = UIColor.assist_D0D0D0
            
        }

		dayLabel.text = "\(cellModel.day)"
	}

    public lazy var circleView: ArcProgressBarView.ArcView = {
		let circleView = ArcProgressBarView.ArcView()
        circleView.shapeLayer.lineDashPattern = [3.0, 3.0]
        circleView.lineWidth = 1.0
        circleView.proportion = 1.0
        circleView.shapeLayer.fillColor = UIColor.clear.cgColor
		return circleView
	}()

	public lazy var dayLabel: Label = {
		let dayLabel = Label()
		dayLabel.font = Fonts.systemFont(ofSize: 16)
		return dayLabel
	}()

}



